package com.xinchen.gufeiwulian.ui.fragment

import android.os.Bundle
import android.view.View
import android.widget.ImageButton
import android.widget.LinearLayout
import android.widget.TextView
import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer
import com.maple.base.base.BaseFragment
import com.maple.utils.ext.toVisible
import com.xinchen.gufeiwulian.R
import com.xinchen.gufeiwulian.vm.AccountViewModel


class SettingFragment : BaseFragment() {

    private val viewModel by viewModels<AccountViewModel>()

    override fun hasNavController(): Boolean  = true
    override fun getLayoutId(): Int = R.layout.fragment_setting

    override fun initView(view: View, savedInstanceState: Bundle?) {
        super.initView(view, savedInstanceState)
        view.findViewById<TextView>(com.maple.res.R.id.tv_title_center)?.text = "设置IP"
        view.findViewById<ImageButton>(com.maple.res.R.id.ibtn_title_left)?.let {
            it.toVisible()
            it.setOnClickListener {
                this.onPopBack()
            }
        }
        view.findViewById<TextView>(com.maple.res.R.id.tv_title_right)?.let {
            it.text = "完成"
            it.toVisible()
        }
        view.findViewById<LinearLayout>(com.maple.res.R.id.ll_title_right)?.let {
            it.toVisible()
            it.setOnClickListener {
                showToast("完成")
            }
        }
    }
    override fun initData(savedInstanceState: Bundle?) {
        viewModel.defUI.showDialog.observe(this, Observer {
            showLoading()
        })

        viewModel.defUI.dismissDialog.observe(this, Observer {
            dismissLoading()
        })

        viewModel.defUI.toastEvent.observe(this, Observer {
            showToast(it)
        })

    }

}